import { ReactElement } from 'react'
import style from './index.module.less'
import { FileSchema } from '../schema/fileSchema'
import { download } from '@js/downloadRename'

interface Props {
  value?: FileSchema[]
}

function Main ({ value = [] }: Props): ReactElement {
  return (
    <div className={style.list}>
      {value.length > 0
        ? value.map((li, i) => {
          return (
            <span className={style.file} key={i}>
              <span>{i + 1}、</span>
              <a onClick={() => download(li.path, li.original_filename)}>{li.original_filename}</a>
            </span>
          )
        })
        : '无'}
    </div>
  )
}

export default Main
